var api = require('../../utils/api.js')
var Ajax = require("../../utils/ajax.js")
var Modal = require("../../utils/modal.js")
var app = getApp()
Page({
  data: {
    
  },
  onShow () {
    this.setData({
      phoneheight: app.globalData.phoneheight,
      fix_position: app.globalData.fix_position
    });
    Ajax.AsyncGet('/grant/get_granted_list/', null, (data) => {
      this.setData({
        members: data.data
      })
    })
  },
  activatemember(e){
    var index = e.currentTarget.dataset.index;
    app.globalData.activemember = this.data.members[index];
  },
  scan(e){
    wx.scanCode({
      success:(res)=>{
        Ajax.AsyncPost('/grant/add_grant_member/', { B_id: res.result}, (data) => {
          this.setData({
            members: data.data
          });
          wx.navigateTo({
            url: '/pages/member_choose_mesh/member_choose_mesh?grantid=' + res.result,
          })
        })
      }
    })
  }
})
